home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Graphics & Imaging / SLUDGE 2.0 / Source Code / Parasite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-14  |  9.7 KB  |  196 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2.   •                                                                           •
  3.   •   File Name:                                                              •
  4.   •   ----------                                                              •
  5.   •                                                                           •
  6.   •   Copyright © 1990 Apple Computer, Inc.  All Rights Reserved              •
  7.   •                                                                           •
  8.   •       Description                                                         •
  9.   •       -----------                                                         •
  10.   •       This file contains the c language portion of the parasite.  The     •
  11.   •          parasite is what slows down your mac.                                  •
  12.   •                                                                           •
  13.   •       History                                                             •
  14.   •       -------                                                             •
  15.   •                                                                           •
  16.   •       Author          Date            Description                         •
  17.   •       ------------------------------------------------------------------  •
  18.   •       Kevin McEntee   2/20/90         Original Implementation             •
  19.   •                                                                           •
  20.   •                                                                           •
  21.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  22. #include    <Types.h>
  23.  
  24. #pragma        segment NUGG
  25.  
  26.  
  27.                                          /*••••••••••••••••••••••••••••••••••••••••••
  28.                                            •                                        •
  29.                                            •    Structure showing the jump-trace    •
  30.                                            •    exception stack frame.                •
  31.                                            •                                        •
  32.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  33. typedef struct {
  34.     short        status_register;
  35.     Ptr            program_counter;
  36.     short        vector_offset;
  37.     char        byte0;
  38.     char        byte1;
  39.     char        byte2;
  40.     char        byte3;
  41.     char        byte4;
  42.     char        byte5;
  43.     char        byte6;
  44.     char        byte7;
  45.     char        byte8;
  46.     char        byte9;
  47.     char        byte10;
  48.     char        byte11;
  49.     char        byte12;
  50.     char        byte13;
  51.     char        byte14;
  52.     char        byte15;
  53. } a_trap_stack_frame;
  54.  
  55.  
  56.  
  57.                                          /*••••••••••••••••••••••••••••••••••••••••••
  58.                                            •                                        •
  59.                                            •    Comment Block.                        •
  60.                                            •                                        •
  61.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  62. Ptr get_a_trap_exception_vector();
  63. void save_system_a_trap_vector(Ptr vector);
  64. void TAKE_A_TRAP_EXCEPTION_VECTOR();
  65.  
  66. Ptr        get_a_trap_stack_frame_program_counter(a_trap_stack_frame *frame);
  67. Ptr        GET_SAVED_A_TRAP_VECTOR();
  68. Handle    GET_MASTER_A_TRAP_HANDLE();
  69. void     SET_JUMP_TRACE_BIT();
  70. void    TAKE_JUMP_TRACE_VECTOR(long sludge_factor);
  71.  
  72.  
  73.  
  74. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  75.   •                                                                           •
  76.   •   Identifier:       start_sludging                                          •
  77.   •   -----------                                                             •
  78.   •                                                                           •
  79.   •       Description                                                         •
  80.   •       -----------                                                         •
  81.   •       This function starts the sludging.  It sets the jump-trace and       •
  82.   •          a-trap exceptions to SLUDGE routines and sets the jump-trace bit    •
  83.   •          in the status register.                                              •
  84.   •                                                                           •
  85.   •       History                                                             •
  86.   •       -------                                                             •
  87.   •                                                                           •
  88.   •       Author          Date            Description                         •
  89.   •       ------------------------------------------------------------------  •
  90.   •       Kevin McEntee   2/20/90         Original Implementation             •
  91.   •                                                                           •
  92.   •                                                                           •
  93.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  94. void start_sludging(long sludge_factor)
  95. {                             
  96.     
  97.     save_system_a_trap_vector( get_a_trap_exception_vector() );  
  98.     
  99.     TAKE_JUMP_TRACE_VECTOR(sludge_factor);
  100.     TAKE_A_TRAP_EXCEPTION_VECTOR();    
  101.     SET_JUMP_TRACE_BIT(); 
  102. }
  103.  
  104.  
  105.  
  106.  
  107. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  108.   •                                                                           •
  109.   •   Identifier:      get_a_trap_exception_vector                             •
  110.   •   -----------                                                             •
  111.   •                                                                           •
  112.   •       Description                                                         •
  113.   •       -----------                                                         •
  114.   •       This function returns the current a-trap exception vector.          •
  115.   •                                                                           •
  116.   •       History                                                             •
  117.   •       -------                                                             •
  118.   •                                                                           •
  119.   •       Author          Date            Description                         •
  120.   •       ------------------------------------------------------------------  •
  121.   •       Kevin McEntee   2/20/90         Original Implementation             •
  122.   •                                                                           •
  123.   •                                                                           •
  124.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  125. Ptr get_a_trap_exception_vector()
  126. {
  127.     Handle vector;
  128.     
  129.     
  130.     vector = (Handle) 0x28; 
  131.     
  132.     return( *vector);
  133.     
  134. }
  135.  
  136.  
  137.  
  138. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  139.   •                                                                           •
  140.   •   Identifier:       HLL_ATRAP_EX                                              •
  141.   •   -----------                                                             •
  142.   •                                                                           •
  143.   •       Description                                                         •
  144.   •       -----------                                                         •
  145.   •       HLL_ATRAP_EX stands for: High Level Language A-Trap Execution.      •
  146.   •          This function is called by SLUDGE's atrap exception handler and     •
  147.   •          returns the system value for the A-Trap exception handler, so the   •
  148.   •          system can process the trap.                                          •
  149.   •                                                                           •
  150.   •       History                                                             •
  151.   •       -------                                                             •
  152.   •                                                                           •
  153.   •       Author          Date            Description                         •
  154.   •       ------------------------------------------------------------------  •
  155.   •       Kevin McEntee   2/20/90         Original Implementation             •
  156.   •                                                                           •
  157.   •                                                                           •
  158.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  159. Ptr        HLL_ATRAP_EX(Handle    register_A0, a_trap_stack_frame *frame)
  160. {
  161.     
  162.     return(GET_SAVED_A_TRAP_VECTOR());
  163. }
  164.  
  165.  
  166. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  167.   •                                                                           •
  168.   •   Identifier:      save_system_a_trap_vector                                  •
  169.   •   -----------                                                             •
  170.   •                                                                           •
  171.   •       Description                                                         •
  172.   •       -----------                                                         •
  173.   •       This function saves the system a-trap exception vector so we can    •
  174.   •          jump to it during a-trap processing.                                  •
  175.   •                                                                           •
  176.   •       History                                                             •
  177.   •       -------                                                             •
  178.   •                                                                           •
  179.   •       Author          Date            Description                         •
  180.   •       ------------------------------------------------------------------  •
  181.   •       Kevin McEntee   2/20/90         Original Implementation             •
  182.   •                                                                           •
  183.   •                                                                           •
  184.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  185. void save_system_a_trap_vector(Ptr vector)
  186. {
  187.     Handle master_handle;
  188.     
  189.     master_handle = GET_MASTER_A_TRAP_HANDLE();
  190.     
  191.     *master_handle = vector;
  192. }
  193.  
  194.  
  195.  
  196.